package cn.jiaqiang.chatgpt.data.infrastructure.dao;

import cn.jiaqiang.chatgpt.data.infrastructure.po.UserModelPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * User: jia-qiang
 * Date: 2024-04-09
 * Time: 22:16
 */
@Mapper
public interface IUserModelDao extends BaseMapper<UserModelPO> {

    /**
     * 查询额度
     * @param userId 用户id
     * @param model 模型
     */
    @Select("SELECT user_id, model, quota from user_model where user_id = #{userId} and model = #{model}")
    UserModelPO queryUserModelPOWithUserIdModel(@Param("userId") Long userId, @Param("model") String model);

    void insertModelPO(UserModelPO userModelPO);

    /** 扣减用户额度 */
    void subAccountQuota(@Param("userId") String userId,@Param("model") String model);

    /** 更新额度 */
    void updateModelPO(UserModelPO userModelPO);
}
